define(["PDUtilDir/grid", "PDUtilDir/searchBlock"], function (Grid,
                                                              SearchBlock) {
    function init(cache, searchObj) {
        SearchBlock.init('searchBillId');
        // 初始化
        return Grid({
            id: "BillGirdDivId",
            pageSize: 10,
            index: true,
            multi: true,
            pagination: true,
            cache: false,
            layout: [
                {
                    name: "团名称",
                    field: "groupName",
                    sort: true,
                    width: '230px',
                },
                {
                    name: "团编号",
                    field: "groupNo",
                    width: '180px',
                    sort: true
                },
                {
                    name: "团人数",
                    field: "personNum",
                    width: '70px',
                    sort: true
                },
                {
                    name: "总团费用",
                    width: '80px',
                    field: "totelCost",
                    sort: true
                }, {
                    name: "总显示价",
                    width: '80px',
                    field: "realSale",
                    sort: true
                },
                {
                    name: "状态",
                    field: "status",
                    sort: true,
                    width: '60px',
                    format: function (e) {
                        return cache.statusMap.get(e.row.status);
                    }
                },
                {
                    name: "负责人",
                    width: '60px',
                    field: "chargePerson"
                },
                {
                    name: "出团时间",
                    field: "departureTime"
                },
                {
                    name: "操作",
                    field: "createTime",
                    sort: false,
                    width: '100px',
                    format: function (e) {
                        var id = e.row.id, groupName = e.row.groupName, str = '';
                        str += '<a href="javascript:angular.element(\'#BillGirdDivId\').scope().detailSupport.run(\'' + e.row.id + '\',\'' + groupName + '\')">查看报帐</a>';
                        str += '<a href="javascript:angular.element(\'#BillGirdDivId\').scope().uploadSupport.run(\'' + e.row.id + '\',\'' + groupName + '\')">报帐</a>';
                        return str;
                    }
                }],
            toolbar: [{
                name: "查询",
                icon: "fa fa-search",
                callback: function (event) {
                    searchObj.run();
                }
            }],
            data: {
                type: 'URL',
                value: getServer()
                + '/flea/hclv/htravelGroup/listMyBackGroup.htmls'
            }
        });
    }

    return {
        init: init
    }
});